//---------------------------------------------------------------------------


#pragma hdrstop

#include "TVCard.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
TVCard::TVCard(Client *client){
	if(NULL!=client){
		_client=client;

	}
	 VCMgr=NULL;

}
//---------------------------------------------------------------------------
TVCard::~TVCard(){
	if(NULL!=VCMgr){
		delete(VCMgr);
	}
}
//---------------------------------------------------------------------------
void TVCard::handleVCard( const JID& jid, const VCard *v ){
	if(FOnVCard)FOnVCard(jid,v);
}

void TVCard::handleVCardResult( VCardContext context, const JID& jid, StanzaError se){
	if(FOnVCardResult)FOnVCardResult( context,jid,se );
}
//---------------------------------------------------------------------------
void __fastcall TVCard::GetVCard(JID jid){
	if(_client->state()!=StateConnected)return;
    if(!VCMgr)VCMgr = new VCardManager( _client );
	VCMgr->fetchVCard(jid,this);
}


void __fastcall TVCard::SaveVCard(VCard *vcard){
	if(_client->state()!=StateConnected)return;
	VCMgr->storeVCard( vcard, this );
}

//---------------------------------------------------------------------------

